<template>
  <div>
    用户发布信息管理

    <el-table :data="invitation.data">
      <el-table-column
        label="id"
        prop="invitation_id"
        width="55"
        align="center"
      ></el-table-column>
      <el-table-column
        label="信息标题"
        prop="invitation_title"
        align="center"
      ></el-table-column>
      <el-table-column
        label="信息内容"
        prop="invitation_content"
        align="center"
        show-overflow-tooltip="true"
      ></el-table-column>
      <el-table-column
        label="发布时间"
        prop="invitation_time"
        align="center"
        width="160"
      ></el-table-column>
      <el-table-column
        label="用户id"
        prop="user_id"
        align="center"
        width="80"
      ></el-table-column>
      <el-table-column label="发布状态" prop="invitation_state" align="center">
        <template slot-scope="scope">
          <div v-if="scope.row.invitation_state == 0">未审核</div>
          <div v-else-if="scope.row.invitation_state == 1">已通过</div>
          <div v-else>
            <el-button type="danger" @click="del(scope.row.invitation_id)"
              >删除</el-button
            >
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import httpApi from "@/http";
export default {
  data() {
    return {
      invitation: {},
    };
  },
  methods: {
    list(num) {
      httpApi.invitationApi.list({ page: num, pagesize: 10 }).then((res) => {
        console.log(res);
        this.invitation = res.data;
      });
    },
    del(id) {
      this.$confirm("将删除这条信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "success",
      }).then(() => {
        httpApi.invitationApi
          .del({ invitation_id: id})
          .then((res) => {
            console.log(res);
            this.list(1);
          });
      });
    },
  },
  mounted() {
    this.list(1);
  },
};
</script>

<style lang="scss" scoped>
</style>